var loginIn = (function (window, $, document, undefined) {
    var basePath = $('#basePath').val();
    /*
     * this method is used to add click event for form's submit button,
     * and submit the form to remote server.
     * */
    function submitForm() {
        $("#submitButton").click(function (event) {
            event.preventDefault();
            console.log(basePath);
            var remoteUrl = basePath + "manage/loginOn.do", $loginForm = $("#loginForm");
            $.ajax({
                url: remoteUrl,
                type: 'POST',
                data: $loginForm.serialize(),
                async: true,
                dataType: 'json',
                error: function () {
                    alert('error');
                },
                success: function (data) {
                    if (data.success) {
                        if (data.success == "1") {
                            location.href = basePath + "skipView/index.do";
                        } else {
                            location.href = basePath + data.success;
                        }
                    } else {
                        $(".leftHide").removeClass("leftHide");
                    }
                }
            })
        });
    }

    return {
        init: function () {
            submitForm();
        }
    }
})(window, jQuery, document);